/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fonol.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Fredfred2
 */
@Entity
@Table(name = "ESTADOS")
@SequenceGenerator(name="seqEst",allocationSize=1,initialValue=1,sequenceName="ESTADOS_SEQ")
@NamedQueries({@NamedQuery(name = "Estados.findByIdestado", query = "SELECT e FROM Estados e WHERE e.idestado = :idestado"), @NamedQuery(name = "Estados.findByNombre", query = "SELECT e FROM Estados e WHERE e.nombre = :nombre")})
public class Estados implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator="seqEst",strategy=GenerationType.SEQUENCE)
    @Column(name = "IDESTADO", nullable = false)
    private Integer idestado;
    @Column(name = "NOMBRE")
    private String nombre;
    @OneToMany(mappedBy = "estado")
    private Collection<Candidatos> candidatosCollection;
    @JoinColumn(name = "IDGOBIERNO", referencedColumnName = "IDGOBIERNO")
    @ManyToOne
    private Gobiernos gobierno;
        @OneToMany(mappedBy = "estado")
    private Collection<Delegados> delegadosCollection;

    public Estados() {
    }

    public Estados(Integer idestado) {
        this.idestado = idestado;
    }

    public Integer getIdestado() {
        return idestado;
    }

    public void setIdestado(Integer idestado) {
        this.idestado = idestado;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Collection<Candidatos> getCandidatosCollection() {
        return candidatosCollection;
    }

    public void setCandidatosCollection(Collection<Candidatos> candidatosCollection) {
        this.candidatosCollection = candidatosCollection;
    }

    public Gobiernos getIdgobierno() {
        return gobierno;
    }

    public void setIdgobierno(Gobiernos idgobierno) {
        this.gobierno = idgobierno;
    }

    public Collection<Delegados> getDelegadosCollection() {
        return delegadosCollection;
    }

    public void setDelegadosCollection(Collection<Delegados> delegadosCollection) {
        this.delegadosCollection = delegadosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idestado != null ? idestado.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString(){
        return this.getNombre();
    }
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Estados)) {
            return false;
        }
        Estados other = (Estados) object;
        if ((this.idestado == null && other.idestado != null) || (this.idestado != null && !this.idestado.equals(other.idestado))) {
            return false;
        }
        return true;
    }


}
